package net.csdn.business.common.feign.webhook;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.csdn.business.common.constant.ServiceNameConstants;
import net.csdn.business.common.domain.query.WebhookConfigQuery;
import net.csdn.business.common.domain.request.webhook.DeleteWebhookConfigDTO;
import net.csdn.business.common.domain.request.webhook.NewWebhookConfigDTO;
import net.csdn.business.common.domain.request.webhook.UpdateWebhookConfigDTO;
import net.csdn.business.common.domain.request.webhook.WebhookRedeliveryDTO;
import net.csdn.business.common.domain.vo.WebHookEvent;
import net.csdn.business.common.domain.vo.WebhookConfigVO;
import net.csdn.business.common.feign.webhook.config.WebHookFeignConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @Auther: zhangyalei
 * @Date: 2023/04/23 16:59
 * @Description: webhook配置相关api
 */
@FeignClient(value = ServiceNameConstants.ATOMGIT_WEBHOOK_SERVICE, contextId = ServiceNameConstants.ATOMGIT_WEBHOOK_CONFIG_CONTEXT_ID,configuration = WebHookFeignConfiguration.class)
public interface WebHookConfigFeignClient {

    /**
     * 分页查询webhook配置信息列表
     */
    @PostMapping("/api/v1/webhook/pagelist")
    public Page<WebhookConfigVO> findPageList(@RequestBody WebhookConfigQuery query);


    /**
     * 根据fromId查询webhook配置信息列表
     */
    @GetMapping("/api/v1/webhook/list/{fromId}")
    public List<WebhookConfigVO> findListByFromId(@PathVariable("fromId")String fromId);

    /**
     * 根据id获取webhook配置信息详细信息
     */
    @GetMapping("/api/v1/webhook/{id}")
    public WebhookConfigVO getInfo(@PathVariable("id") String id);

    /**
     * 新增webhook配置信息
     */
    @PostMapping("/api/v1/webhook/add")
    public String add(@RequestBody NewWebhookConfigDTO webhookConfig);

    /**
     * 修改webhook配置信息
     */
    @PostMapping("/api/v1/webhook/update")
    public Integer update(@RequestBody UpdateWebhookConfigDTO webhookConfig);

    /**
     * 删除webhook配置信息
     */
    @PostMapping("/api/v1/webhook/delete")
    public Integer delete(@RequestBody DeleteWebhookConfigDTO param);

    /**
     * 查询组织、项目、issue的webhook的事件
     */
    @GetMapping("/api/v1/webhook/event/{type}")
    public List<WebHookEvent> getEvent(@PathVariable("type") String type);

    /**
     * webhookEvent重新发送通知
     */
    @PostMapping("/api/v1/webhook/event/redelivery")
    public Integer redelivery(@RequestBody WebhookRedeliveryDTO params);
}